package com.jrzh.mvc.search.sys;

import org.apache.commons.lang.StringUtils;

import com.jrzh.framework.base.search.BaseSearch;
import com.jrzh.framework.searchutils.Criteria;
import com.jrzh.framework.searchutils.Restrictions;

public class ResourcesSearch extends BaseSearch{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2225076826507332112L;
	
	private Object[] inIds;
	
	private Object[] inTypes;
	
	private Boolean equalIsDisable;
	
	private String equalPid;
	
	private Object[] notInCodes;
	
	private Boolean isNullPid;
	
	private String isNotNullCode;
	
	private String likeHeadCode;
	
	private String eqCode;
	
	private Integer eqLevel;
	
	private Boolean eqIsCustom;
	
	
	public Integer getEqLevel() {
		return eqLevel;
	}

	public void setEqLevel(Integer eqLevel) {
		this.eqLevel = eqLevel;
	}

	public String getEqCode() {
		return eqCode;
	}

	public void setEqCode(String eqCode) {
		this.eqCode = eqCode;
	}

	public String getIsNotNullCode() {
		return isNotNullCode;
	}

	public void setIsNotNullCode(String isNotNullCode) {
		this.isNotNullCode = isNotNullCode;
	}

	public Object[] getInIds() {
		return inIds;
	}

	public void setInIds(Object[] inIds) {
		this.inIds = inIds;
	}
	
	public Object[] getInTypes() {
		return inTypes;
	}

	public void setInTypes(Object[] inTypes) {
		this.inTypes = inTypes;
	}
	
	public Boolean getEqIsCustom() {
		return eqIsCustom;
	}

	public void setEqIsCustom(Boolean eqIsCustom) {
		this.eqIsCustom = eqIsCustom;
	}

	@Override
	public void setCriterias(Criteria<?> criterias) {
		if(StringUtils.isNotBlank(eqCode)){
			criterias.add(Restrictions.eq("code",eqCode));
		}
		if(StringUtils.isNotBlank(isNotNullCode)){
			criterias.add(Restrictions.isNotNull(isNotNullCode));
		}
		if(null != inIds && inIds.length > 0){
			criterias.add(Restrictions.in("id", inIds));
		}
		if(null != inTypes && inTypes.length > 0){
			criterias.add(Restrictions.in("type", inTypes));
		}
		if(null != equalIsDisable){
			criterias.add(Restrictions.eq("isDisable", equalIsDisable));
		}
		if(StringUtils.isNotBlank(equalPid)){
			criterias.add(Restrictions.eq("pid", equalPid));
		}
		if(null != notInCodes && notInCodes.length > 0){
			criterias.add(Restrictions.notIn("code", null, notInCodes));
		}
		if(null != isNullPid){
			criterias.add(Restrictions.or(Restrictions.isNull("pid"), Restrictions.eq("pid", "")));
		}
		if(StringUtils.isNotBlank(likeHeadCode)){
			criterias.add(Restrictions.like("code", likeHeadCode +"%"));
		}
		if(null != eqLevel){
			criterias.add(Restrictions.eq("level", eqLevel));
		}
		if(null != eqIsCustom){
			criterias.add(Restrictions.eq("isCustom", eqIsCustom));
		}
	}

	public Boolean getEqualIsDisable() {
		return equalIsDisable;
	}

	public void setEqualIsDisable(Boolean equalIsDisable) {
		this.equalIsDisable = equalIsDisable;
	}

	public String getEqualPid() {
		return equalPid;
	}

	public void setEqualPid(String equalPid) {
		this.equalPid = equalPid;
	}

	public Object[] getNotInCodes() {
		return notInCodes;
	}

	public void setNotInCodes(Object[] notInCodes) {
		this.notInCodes = notInCodes;
	}

	public Boolean getIsNullPid() {
		return isNullPid;
	}

	public void setIsNullPid(Boolean isNullPid) {
		this.isNullPid = isNullPid;
	}

	public String getLikeHeadCode() {
		return likeHeadCode;
	}

	public void setLikeHeadCode(String likeHeadCode) {
		this.likeHeadCode = likeHeadCode;
	}
}
